home *** CD-ROM | disk | FTP | other *** search
- // Routine sur les boites et borders V0.27
- // (C) 1992 Christophe PASSUELLO
- // Mon Jan 25 21:15:35 1993
-
-
- #include <mytypes.h>
- #include <exec/types.h>
- #define INTUITION_PREFERENCES_H 0
- #include <graphics/rastport.h>
- #include <graphics/gfxmacros.h>
- #include "IObject_priv.h"
-
-
- UBYTE BackPen=0;
- UBYTE LightPen=2;
- UBYTE DarkPen=1;
- UBYTE Pen1=1;
- UBYTE Pen2=2;
-
-
- //
- // Initialise les couleurs
- //
- VOID SetIObjectColors(UBYTE back, UBYTE light, UBYTE dark, UBYTE pen1, UBYTE pen2)
- {
- BackPen = back;
- LightPen = light;
- DarkPen = dark;
- Pen1 = pen1;
- Pen2 = pen2;
- }
-
-
- //
- // Dessine une boite en 3D en modifiant le DrawEnv
- //
- VOID FastDraw3DBox(struct Box *box, struct RastPort *rp, UWORD kind)
- {
- // dessiner deux boites ?
- if ((kind == BOX_2IN) || (kind == BOX_2OUT))
- {
- struct Box tmpbox;
-
- FastDraw3DBox(box, rp, (kind == BOX_2IN ? BOX_1IN : BOX_1OUT));
-
- tmpbox = *box;
- tmpbox.x += 2;
- tmpbox.y++;
- tmpbox.w -= 4;
- tmpbox.h -= 2;
-
- FastDraw3DBox(&tmpbox, rp, (kind == BOX_2IN ? BOX_1OUT : BOX_1IN));
- }
- else
- {
- // dessiner une boite
- WORD x2, y2;
-
- x2 = box->x + box->w - 1;
- y2 = box->y + box->h - 1;
-
- SetDrMd(rp, JAM1);
-
- /* dessine le light */
- SetAPen(rp, (kind == BOX_1OUT ? LightPen : DarkPen));
- Move(rp, x2, box->y);
- Draw(rp, box->x, box->y);
- Draw(rp, box->x, y2);
- Move(rp, box->x + 1, box->y);
- Draw(rp, box->x + 1, y2);
-
- /* dessine le dark */
- SetAPen(rp, (kind == BOX_1OUT ? DarkPen : LightPen));
- Move(rp, x2, box->y);
- Draw(rp, x2, y2);
- Draw(rp, box->x + 1, y2);
- Move(rp, x2 - 1, box->y + 1);
- Draw(rp, x2 - 1, y2);
- }
- }
-
-
- //
- // Inverse une boite
- //
- VOID ComplementBox(struct Box *box, struct RastPort *rp)
- {
- UBYTE drmd;
-
- drmd = rp->DrawMode;
- SetDrMd(rp, COMPLEMENT);
- RectFill(rp, box->x, box->y, box->x + box->w - 1, box->y + box->h - 1);
- SetDrMd(rp, drmd);
- }
-
- //
- // Dessine une boite en 3D
- //
- VOID Draw3DBox(struct Box *box, struct RastPort *rp, UWORD kind)
- {
- struct DrawEnv env;
-
- SaveDrawEnv(rp, &env);
- FastDraw3DBox(box, rp, kind);
- RestoreDrawEnv(rp, &env);
- }
-
-
- //
- // Remplit une boite avec une couleur
- //
- VOID FastFillBox(struct Box *box, struct RastPort *rp, UBYTE coul)
- {
- SetDrMd(rp, JAM1);
- SetAPen(rp, coul);
- RectFill(rp, box->x, box->y, box->x + box->w - 1, box->y + box->h - 1);
- }
-
-
- //
- // Remplit une boite avec une couleur
- //
- VOID FillBox(struct Box *box, struct RastPort *rp, UBYTE coul)
- {
- struct DrawEnv env;
-
- SaveDrawEnv(rp, &env);
- FastFillBox(box, rp, coul);
- RestoreDrawEnv(rp, &env);
- }
-
-
- //
- // efface une boite avec la couleur coul en modifiant le DrawEnv
- //
- VOID FastEraseBox(struct Box *box, struct RastPort *rp)
- {
- FastFillBox(box, rp, 0);
- }
-
-
- //
- // efface une boite avec la couleur coul
- //
- VOID EraseBox (struct Box *box, struct RastPort *rp)
- {
- struct DrawEnv env;
-
- SaveDrawEnv(rp, &env);
- FastEraseBox(box, rp);
- RestoreDrawEnv(rp, &env);
- }
-
-
- //
- // Sauve l'environnement de dessin
- //
- VOID SaveDrawEnv(struct RastPort *rp, struct DrawEnv *env)
- {
- env->APen = rp->FgPen;
- env->BPen = rp->BgPen;
- env->DrMd = rp->DrawMode;
- }
-
-
- //
- // Restaure l'environnement de dessin
- //
- VOID RestoreDrawEnv(struct RastPort *rp, struct DrawEnv *env)
- {
- SetAPen(rp, env->APen);
- SetBPen(rp, env->BPen);
- SetDrMd(rp, env->DrMd);
- }
-
-
- //
- // Sauve l'environnement Texte
- //
- VOID SaveTextEnv(struct RastPort *rp, struct TextEnv *env)
- {
- env->Font = rp->Font;
- SaveDrawEnv(rp, &env->Env);
- }
-
-
- //
- // Restaure l'environnement texte
- //
- VOID RestoreTextEnv(struct RastPort *rp, struct TextEnv *env)
- {
- RestoreDrawEnv(rp, &env->Env);
- SetFont(rp, env->Font);
- }
-